{template 'common/header'}
{php echo $this -> set_tabbar($action, $storeid);}
{if $operation == 'display'}
<link rel="stylesheet" type="text/css" href="{RES}/css/main.css"/>
<div class="main">
    <div class="panel panel-default">
        <div class="panel-body">
            <div class="row">
                <ul class="nav nav-pills" role="tablist">
                    <li>
                        <a href="{php echo $this->createWebUrl('parkzones', array('op' => 'display', 'storeid' => $storeid))}">停车场类型</a>
                    </li>
                    <li class="active">
                        <a href="{php echo $this->createWebUrl('park', array('op' => 'display', 'storeid' => $storeid))}">车位管理</a>
                    </li>
                </ul>
            </div>
            <div class="header">
                <h3>车位 列表</h3>
            </div>
            <div class="form-group">
                <a class="btn btn-success btn-sm" href="{php echo $this->createWebUrl('park', array('op' => 'display', 'storeid' => $storeid, 'type' => 'state'))}"><i class="fa fa-circle-o"></i> 车位状态</a>
                <a class="btn btn-success btn-sm" href="{php echo $this->createWebUrl('park', array('op' => 'display', 'storeid' => $storeid, 'type' => 'qrcode'))}"><i class="fa fa-qrcode"></i> 二维码</a>
                <a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('park', array('op' => 'post', 'storeid' => $storeid))}">新建 车位</a>
                <a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('park', array('op' => 'batch', 'storeid' => $storeid))}">批量新建</a>
                <div class="form-group inline-form" style="display: inline-block;">
                    <form accept-charset="UTF-8" action="./index.php" class="form-inline" id="diandanbao/table_search" method="get" role="form">
                        <div style="margin:0;padding:0;display:inline">
                        <input name="utf8" type="hidden" value="✓"></div>
                        <input type="hidden" name="c" value="site" />
                        <input type="hidden" name="a" value="entry" />
                        <input type="hidden" name="m" value="smart_ct" />
                        <input type="hidden" name="do" value="park" />
                        <input type="hidden" name="storeid" value="{$storeid}" />
                        <div class="form-group">
                            <label class="sr-only" for="q_name">名字(车位号)</label>
                            <input class="form-control" id="keyword" name="keyword" placeholder="名字(车位号)" type="search">
                        </div>
                        <div class="form-group">
                            <label class="sr-only" for="q_table_zone_id_eq">Table zone 等于</label>
                            <select id="tablezonesid" name="parkzonesid" class="form-control-excel">
                                <option value="">车位类型</option>
                                {loop $parkzones $row}
                                <option value="{$row['id']}" {if $row['id'] == $item['parkzonesid'] || $row['id'] == $parkzonesid} selected="selected"{/if}>{$row['title']}</option>
                                {/loop}
                            </select>
                        </div>
                        <input class="btn btn-sm btn-success" name="commit" type="submit" value="搜索">
                        <!--<a class="btn btn-success btn-sm" data-remote="true" href="">批量导出车位二维码供打印(横版)</a>-->
                        <!--<a class="btn btn-primary btn-sm" data-remote="true" href="">批量导出车位二维码供打印(竖版)</a>-->
                    </form>
                </div>
            </div>
            <div id="queue-setting-index-body">
            {if $type == 'state'}
            <div class="table-state-tables">
               <ul class='ul_table_sl'>
                   {loop $parkzones $item}
                   <li>
                        <div class='sl_div'>
                            <div class='sl_div2'> 
                                <div class='sl_div3' >
                                    <div style="height: 195px;">
                                        <img src="{php echo tomedia($item['imgpic']);}" class='sl_img' alt="">
                                        <span class='sl_span'>{$item['title']}</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                    {/loop}
                  <!--   <li>
                        <div class='sl_div'>
                            <div class='sl_div2'> 
                                <div class='sl_div3' >
                                    <div style="height: 195px;">
                                        <img src="http://localhost/ZhiH2/web/resource/images/gw-wx.gif"class='sl_img' alt="">
                                        <span class='sl_span'>大厅平面展示图</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                    <li>
                        <div class='sl_div'>
                            <div class='sl_div2'> 
                                <div class='sl_div3' >
                                    <div style="height: 195px;">
                                        <img src="http://localhost/ZhiH2/web/resource/images/gw-wx.gif"class='sl_img' alt="">
                                        <span class='sl_span'>大厅平面展示图</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                 -->
               </ul>
                
                <div class="col-xs-12" style="float: right;width: 70% !important;padding-left: 0px;">
                    {loop $list $item}
                    {if $item['status']==0}
                    {php $status = 'idle';}
                    {php $title = '空闲';}
                    {elseif $item['status']==1}
                    {php $status = 'opened';}
                    {php $title = '已开台';}
                    {elseif $item['status']==2}
                    {php $status = 'ordered';}
                    {php $title = '已下单';}
                    {elseif $item['status']==3}
                    {php $status = 'paid';}
                    {php $title = '已支付';}
                    {/if}
                    <div class="state-table" data-id="{$item['id']}">
                        <div style="margin-right: 20px;">
                            <a class="{$status} round" href="{php echo $this->createWebUrl('park', array('op' => 'detail', 'storeid' => $storeid, 'parkid' => $item['id']))}" data-remote="" title="点击查看订单详情">
                            <div class="state">{$title}</div>
                            </a>
                            <div class="name overflow-ellipsis">
                                <span><a href="{php echo $this->createWebUrl('park', array('op' => 'detail', 'storeid' => $storeid, 'parkid' => $item['id']))}">{$item['title']}</a></span>
                                <form accept-charset="UTF-8" action="{php echo $this->createWebUrl('park', array('op' => 'updatestate', 'storeid' => $storeid, 'parkid' => $item['id']))}" data-remote="true" method="post" style="display:inline-block;">
                                    <div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓">
                                        <input name="_method" type="hidden" value="PUT">
                                    </div>
                                    <select id="workflow_state" name="workflow_state" onchange="$(this.form).submit();">
                                        <option value="0" {if $item['status']==0}selected="selected"{/if}>空闲</option>
                                        <option value="1" {if $item['status']==1}selected="selected"{/if}>已开台</option>
                                        <option value="2" {if $item['status']==2}selected="selected"{/if}>已下单</option>
                                        <!--<option selected="selected" value="check_outing">结帐中</option>-->
                                        <option value="3" {if $item['status']==3}selected="selected"{/if}>已支付</option>
                                    </select>
                                </form>
                            </div>
                        </div>
                    </div>
                    {/loop}
                </div>
                <div class="col-xs-4">
                    <div class="table-order"></div>
                </div>
                <div class="clearfix"></div>
            </div>
            {else}
            <div class="alert alert-success">
                将如下车位二维码打印并分别贴在对应车位上，即可实现扫码下单的功能。微信用户到店后只需拿起微信轻轻一扫，即可实现全自动点菜下单。
            </div>
            <div class="qr-code-table">
                {loop $list $item}
                {if $item['status']==0}
                {php $status = 'idle';}
                {php $title = '空闲';}
                {elseif $item['status']==1}
                {php $status = 'opened';}
                {php $title = '已开台';}
                {elseif $item['status']==2}
                {php $status = 'ordered';}
                {php $title = '已下单';}
                {elseif $item['status']==3}
                {php $status = 'paid';}
                {php $title = '已支付';}
                {/if}
                    <div class="qr-code-item">
                        <div class="qr-code-op">
                            <a data-rel="tooltip" href="{php echo $this->createWebUrl('park', array('id' => $item['id'], 'storeid' => $storeid, 'op' => 'post'))}" title="编辑"><icon class="fa fa-edit"></icon></a>
                            <a data-confirm="确定删除?" data-method="delete" data-rel="tooltip" href="{php echo $this->createWebUrl('park', array('id' => $item['id'], 'storeid' => $storeid, 'op' => 'delete'))}" onclick="return confirm('确认操作吗？');return false;" rel="nofollow" title="删除"><icon class="fa fa-trash-o"></icon></a>
                        </div>
                        <a href="{php echo $this->createWebUrl('park', array('op' => 'detail', 'storeid' => $storeid, 'parkid' => $item['id']))}">
                            <div class="qr-code-box">
                                <div class="qr-code-item-image">
                                    <img alt="{$item['title']}" src="{php echo $this->fm_qrcode($_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=entry&mode=1&storeid=' . $storeid . '&parkid=' . $item['id'] . '&do=waplist&m=smart_ct', 'qrcode_' . $item['id'], '', $logo);}" width="100%">
                                </div>
                                <div class="qr-code-item-info">
                                    {$item['title']}
                                </div>
                            </div>
                            <div class="qr-code-item-footer">
                                扫描次数: {if empty($parkorder[$item['id']]['count'])}0{else}{$parkorder[$item['id']]['count']}{/if}
                                <br>
                                当前状态:
                                <span class="label label-info">{$title}</span>
                                <br>
                                车位类型: {$parkzones[$item['parkzonesid']]['title']}
                            </div>
                        </a>
                    </div>
                {/loop}
                <div class="space"></div>
                </div>
            {/if}
            <div class="clearfix"></div>
        </div>
        </div>
    </div>
</div>
{elseif $operation == 'batch'}
<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <input type="hidden" name="storeid" value="{$storeid}" />
        <input type="hidden" name="id" value="{$item['id']}" />
        <div class="panel panel-default">
            <div class="panel-heading">
                批量创建车位
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">起始车位号</label>
                    <div class="col-sm-9">
                        <input type="text" name="title" class="form-control" value="{$item['title']}"  placeholder=""/>
                        <span class="help-block">例如：C001</span>
                    </div>
                </div> 
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">车位类型</label>
                    <div class="col-sm-9">
                        <select class="form-control" style="margin-right:15px;" name="parkzonesid" autocomplete="off" class="form-control">
                            {loop $parkzones $row}
                            <option value="{$row['id']}" {if $row['id'] == $item['parkzonesid'] || $row['id'] == $parkzonesid} selected="selected"{/if}>{$row['title']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">创建车位数量</label>
                    <div class="col-sm-9">
                        <input type="number" name="park_count" class="form-control" value="{$item['park_count']}" placeholder=""/>
                        <span class="help-block">
                            根据创建的车位数量，系统会自动依据起始车位台号依次递增,<br/> 例如C001, C002, C003, C004.....,一次最多创建10张车位台
                        </span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
                    <div class="col-sm-9">
                        <input type="text" name="displayorder" class="form-control" value="{$item['displayorder']}" />
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group col-sm-12">
            <input type="submit" name="submit" value="创建" class="btn btn-primary col-lg-1" />
            <input type="hidden" name="token" value="{$_W['token']}" />
        </div>
    </form>
</div>
{elseif $operation == 'post'}
<div class="main">
    <form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
        <input type="hidden" name="storeid" value="{$storeid}" />
        <input type="hidden" name="id" value="{$item['id']}" />
        <div class="panel panel-default">
            <div class="panel-heading">
                车位 详情
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">名字(车位号)</label>
                    <div class="col-sm-9">
                        <input type="text" name="title" class="form-control" value="{$item['title']}"  placeholder=""/>
                        <span class="help-block">例如：C001</span>
                    </div>
                </div> 
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">车位类型</label>
                    <div class="col-sm-9">
                        <select class="form-control" style="margin-right:15px;" name="parkzonesid" autocomplete="off" class="form-control">
                            {loop $parkzones $row}
                            <option value="{$row['id']}" {if $row['id'] == $item['parkzonesid'] || $row['id'] == $parkzonesid} selected="selected"{/if}>{$row['title']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
                    <div class="col-sm-9">
                        <input type="text" name="displayorder" class="form-control" value="{$item['displayorder']}" />
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group col-sm-12">
            <input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
            <input type="hidden" name="token" value="{$_W['token']}" />
        </div>
    </form>
</div>
{elseif $operation == 'detail'}
<link rel="stylesheet" type="text/css" href="{RES}/css/main.css"/>
<div class="main">
    <div class="panel panel-default">
        <div class="panel-body">
            <div class="header">
                <h3>车位 详情</h3>
            </div>
            <div class="model-show">
                <p>
                    <b>
                        名字(车位号)
                        :
                    </b>
                    {$item['title']}
                </p>
                <p>
                    <b>
                       车位类型
                        :
                    </b>
                    {$cate['title']}
                </p> 
                <p>
                    <b>
                        当前状态
                        :
                    </b>
                    {if $item['status']==0}空闲{elseif $item['status']==1}已开台{elseif $item['status']==2}已下单{elseif $item['status']==3}已支付{/if}
                </p>
                <p>
                    <b>
                        扫描人数
                        :
                    </b>
                    {if empty($parkorderuser)}0{else}{$parkorderuser}{/if}
                </p>
                <p>
                    <b>
                        所属门店
                        :
                    </b>
                    {$store['title']}
                </p>
                <p>
                    <b>
                        扫描次数
                        :
                    </b>
                    {if empty($parksorder)}0{else}{$parkorder}{/if}
                </p>
                <p>
                    <b>
                        排序
                        :
                    </b>
                    {$item['displayorder']}
                </p>
                <p>
                    <b>
                        二维码图片
                        :
                    </b>
                    <img alt="" src="{php echo$this->fm_qrcode($_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=entry&mode=1&storeid=' . $storeid . '&parkid=' . $item['id'] . '&do=waplist&m=smart_ct', 'qrcode_' . $item['id'], '', $logo);}">
                </p>
                <div class="space"></div>
            </div>
            <div class="qrcode-scan-relations">
                <table class="table table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>扫描者</th>
                        <th>扫描时间</th>
                        <th>扫描者</th>
                        <th>扫描时间</th>
                        <th>扫描者</th>
                        <th>扫描时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    {php $isbegin=false;}
                    {php $rowindex=1;}
                    {loop $orderlist $item}
                    {php $r = $rowindex%3}
                    {if $isbegin==false}
                    {if $r==1}
                    <tr>
                        {php $isbegin=true;}
                    {/if}
                    {/if}
                        <td>
                            <img alt="0" src="{php echo $item['headimgurl'];}" width="50">
                            <a href="#">{$item['nickname']} - {$item['from_user']}</a>
                        </td>
                        <td>{php echo date('Y-m-d <br> H:i:s', $item['dateline'])}</td>
                        {if $isbegin==true}
                        {if $r==0}
                        </tr>
                        {php $isbegin=false;}
                        {/if}
                        {/if}
                    {php $rowindex++;}
                    {/loop}

                    {if $isbegin==true}
                    </tr>
                    {php $isbegin=false;}
                    {/if}
                    </tbody>
                </table>
                <br>
                <div class="pull-left"></div>
                <br>
                <div class="clearfix"></div>
            </div>
            <a class="btn btn-primary btn-sm" href="{php echo $this->createWebUrl('park', array('op' => 'post', 'storeid' => $storeid, 'id' => $parkid))}">编辑</a>
            <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('park', array('op' => 'display', 'storeid' => $storeid))}">返回</a>
        </div>
    </div>
</div>
{/if}
{template 'common/footer'}